﻿using LightCube.Transform;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LightCube.Scene
{
    public class MoveScene : IScene
    {
        private Buffer3D buffer;
        private TranslationTransform translation;
        private int duration;
        private int i;

        public MoveScene(int size, IShape[] shapes, Point3D speed, int duration, bool wrap)
        {
            buffer = new Buffer3D(size);
            foreach (var shape in shapes)
            {
                shape.Draw(buffer);
            }

            translation = new TranslationTransform(speed, wrap);
            this.duration = duration;
            this.i = 0;
        }

        public bool DrawFrame(Buffer3D buffer)
        {
            if (i > 0)
                translation.Transform(this.buffer);

            buffer.Fuse(this.buffer);

            return ++i < duration;
        }
    }
}
